﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ExportToWeb.CUiExportToWebCmd
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Forms;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.PrivateImplementationDetails;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands.ExportToWeb;

public class CUiExportToWebCmd : TxButtonCommand
{
  private CUiExportToWebEnabler m_enabler;

  public CUiExportToWebCmd() => this.m_enabler = new CUiExportToWebEnabler();

  public virtual ITxCommandEnabler CommandEnabler => (ITxCommandEnabler) this.m_enabler;

  public virtual string Category
  {
    get => CApExportToWebUtilities.GetResourceManager().GetString("CMD_CATEGORY");
  }

  public virtual string Name => CApExportToWebUtilities.GetResourceManager().GetString("CMD_NAME");

  public virtual string Tooltip
  {
    get => CApExportToWebUtilities.GetResourceManager().GetString("CMD_TOOLTIP");
  }

  public virtual string Description
  {
    get => CApExportToWebUtilities.GetResourceManager().GetString("CMD_DESCRIPTION");
  }

  public virtual string Bitmap => "ExportToWeb.Resources.ExportToWebIcon.png";

  public virtual string LargeBitmap => "ExportToWeb.Resources.ExportToWebIcon_LARGE.png";

  public virtual ITxImage Image => (ITxImage) TxImageManager.GetImageByKey("ExportToWeb");

  public virtual void Execute(object cmdParams)
  {
    if (CApExportToWebUtilities.IsGraphicViewerEmpty())
    {
      int num = (int) TxMessageBox.Show(CApExportToWebUtilities.GetResourceManager().GetString("ERROR_EMPTY_GRAPHIC_VIEWER"), CApExportToWebUtilities.GetResourceManager().GetString("CMD_NAME"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
    }
    else
      this.RunDialog();
  }

  private void RunDialog()
  {
    ITxOperation selectedOperation = this.GetSelectedOperation();
    if (TxTcUtilities.IsTcAnyPlatform)
      ((Window) new CUiExportToWebTCDialog(selectedOperation)).Show();
    else
      ((Window) new CUiExportToWebDialog(selectedOperation)).Show();
  }

  private ITxOperation GetSelectedOperation()
  {
    TxSelection activeSelection = TxApplication.ActiveSelection;
    ITxOperation selectedOperation = (ITxOperation) null;
    if (activeSelection.Count == 1 && !(((Collection<ITxObject>) activeSelection.GetItems())[0] is ITxLocationOperation) && !(((Collection<ITxObject>) activeSelection.GetItems())[0] is ITxHumanCompoundOperation) && !(((Collection<ITxObject>) activeSelection.GetItems())[0] is ITxHumanFingerOperation) && !(((Collection<ITxObject>) activeSelection.GetItems())[0] is ITxHumanPlacementOperation) && !(((Collection<ITxObject>) activeSelection.GetItems())[0] is ITxHumanPostureOperation) && !(((Collection<ITxObject>) activeSelection.GetItems())[0] is ITxHumanReachOperation) && !(((Collection<ITxObject>) activeSelection.GetItems())[0] is ITxHumanWalkOperation) && !(((Collection<ITxObject>) activeSelection.GetItems())[0] is ITxLocationOperation))
      selectedOperation = ((Collection<ITxObject>) activeSelection.GetItems())[0] as ITxOperation;
    return selectedOperation;
  }
}
